package com.cx330;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.Date;

public class Example47 {
    public static void main(String[] args) {
        Date date = new Date();
        System.out.println(date);
        date.setTime(123456789L); // 修改Date对象
        System.out.println(date);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dateStr = sdf.format(date); // 格式化
        System.out.println(dateStr);
        System.out.println("=================================");
        LocalDateTime now = LocalDateTime.now();
        System.out.println(now);
        LocalDateTime future = now.plusDays(100);
        System.out.println(future);
        DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).withZone(ZoneId.of("Asia/Shanghai"));
        String datetimeStr = dtf.format(future);
        System.out.println(datetimeStr);
    }
}
